package com.chixing.ih.module.programmer.mapper;

import com.chixing.ih.common.IhRepository;
import com.chixing.ih.module.programmer.mapper.provider.EvaluateMapperProvider;
import com.chixing.ih.module.programmer.pojo.Evaluate;
import com.chixing.ih.module.programmer.pojo.dto.EvaluateDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-09-30
 * Time: 8:44
 *
 * @version 1.0
 */
@Mapper
public interface EvaluateMapper extends IhRepository<Evaluate> {

    @UpdateProvider(type = EvaluateMapperProvider.class, method = "updateOne")
    int updateOne(Evaluate evaluate);

    @SelectProvider(type = EvaluateMapperProvider.class, method = "listAll")
    @Results(id = "evaluateMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "user_evaluate_id", property = "userEvaluateId"),
            @Result(column = "user_evaluated_id", property = "userEvaluatedId"),
            @Result(column = "skill_score", property = "skillScore"),
            @Result(column = "attitude_score", property = "attitudeScore"),
            @Result(column = "punctuality_score", property = "punctualityScore"),
            @Result(column = "evaluated_desc", property = "evaluatedDesc"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "is_deleted", property = "isDeleted")
    })
    List<EvaluateDTO> listAll(long userEvaluatedId);

    @InsertProvider(type = EvaluateMapperProvider.class, method = "insertOne")
    int insertOne(Evaluate evaluate);

    @DeleteProvider(type = EvaluateMapperProvider.class, method = "deleteOneById")
    int deleteOne(long id);

    @SelectProvider(type = EvaluateMapperProvider.class, method = "getStarRating")
    Double getStarRating(long userEvaluatedId);


}
